#define DEBUG
#include <cstdio>

using namespace std;

const int maxm=100000, maxn=10000000;

inline int max(int a, int b) {
  return a>b ? a : b;
}

int main() {
#ifdef DEBUG
  freopen("3318.in", "r", stdin);
  freopen("3318.out", "w", stdout);
#endif

  static int p[maxm+1], book[maxn+1], f[maxn+1], ans[maxn+1];
  int m, q;
  scanf("%d %d", &m, &q);
  for (int i=1; i<=m; i++) {
    scanf("%d", p+i);
  }

  for (int i=1; i<=m; i++) {
    for (int j=p[i]; j<=maxn; j+=p[i]) {
      book[j] = max(book[j], p[i]);
    }
  }
  f[1]=p[m]-1;
  for (int i=1, j=1; i<=maxn; i++) {
    for (; f[j]<i && f[j]; ) {
      j++;
    }
    if (f[j]) {
      ans[i]=j;
      f[j+1] = max(f[j+1], i+book[i]-1);
    } else {
      break;
    }
  }

  for (int i=1; i<=q; i++) {
    int n;
    scanf("%d", &n);
    printf(ans[n]>0 ? "%d\n" : "oo\n", ans[n]);
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
